package com.ermace.robo.jumper;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ViewFlipper;

import com.ermace.robo.jumper.game.Game;
import com.ermace.robo.jumper.game.Map;
import com.ermace.robo.jumper.game.MapList;

public class MapSelectionActivity extends Activity {

	private Intent intent;
//	private MapList maps;
	private boolean backPressed = false;
	View.OnTouchListener gestureListener;
	
	private MapSelectionView mpView;
	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        //Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
//        slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.move_left_in);
//        slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.move_left_out);
//        slideRightIn = AnimationUtils.loadAnimation(this, R.anim.move_right_in);
//        slideRightOut = AnimationUtils.loadAnimation(this, R.anim.move_right_out);
//        slideUp = AnimationUtils.loadAnimation(this, R.anim.move_up);
//        slideDown = AnimationUtils.loadAnimation(this, R.anim.move_down);
//        
//        gestureDetector = new GestureDetector(this, new MyGestureDetector());
        
        setContentView(R.layout.selection);
        
        mpView = (MapSelectionView) findViewById(R.id.mapSelectionView);
        
        intent = new Intent(this, Game.class);
        
        mpView.setIntent(intent);
//        
//        parameters = getSharedPreferences("parameters", MODE_PRIVATE);
//        
//        flipper = (ViewFlipper) findViewById(R.id.flipper);
//        flipperTitle = (ViewFlipper) findViewById(R.id.flipperTitle);
//        
//        refreshMaps();
//       
        
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent event) {
    	return mpView.handleEvent(event);
    }
    
	@Override
	protected void onResume() {
		super.onResume();
			MainActivity.resumeMusic();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
			if(!backPressed )
				MainActivity.pauseMusic();
	}
	
	@Override
	public void onBackPressed() {
		backPressed = true;
		super.onBackPressed();
	}
	
}
